#!/usr/bin/env python2.3

from activist.DataStore import DataStore
from activist.MetaData import MetaData
from activist.Person import Person
from activist.PersonInformation import PersonInformation
from activist.Event import Event
from activist.EventInformation import EventInformation
from activist.Group import Group
from activist.GroupInformation import GroupInformation
from activist.Place import Place
from activist.Person import Person
from activist.Users import Users
from activist.CommandProcessor import CommandProcessor

CommandProcessor.loadAndProcess()


##
## test Person and related commands
##

p = Person()
p.create("mike",
         "mikeusername",
         "",
         ["123-4567","432-1111"],
         ["foo@bar.com", "bar@foo.com"],
         "#123 fake street",
         "i am the bio",
         False)

print "person:",p
assert(p.name() == "mike")
assert(p.username() == "mikeusername")
assert(DataStore[p.id()] == p)
assert(p.phone()[0] == "123-4567")
assert(p.phone()[1] == "432-1111")
assert(Users["mikeusername"][1] == p.id())

p.edit(p,
       "mike warren",
       ["123-4567","432-1111"],
       ["foo@bar.com", "bar@foo.com"],
       "#123 fake street",
       "i am the bio",
       False)

assert(len(p.metadataInverseTargetsForRelationship(MetaData.InformationOf)) == 2)
assert(p.name() == "mike warren")

p.make_administrator(p, True)
assert(p in DataStore['administrator'].sourcesForRelationship(MetaData.BelongsWith))
p.make_administrator(p, False)
assert(p not in DataStore['administrator'].sourcesForRelationship(MetaData.BelongsWith))


p.make_moderator(p, True)
assert(p in DataStore['moderator'].sourcesForRelationship(MetaData.BelongsWith))
p.make_moderator(p, False)
assert(p not in DataStore['moderator'].sourcesForRelationship(MetaData.BelongsWith))

p.make_commentator(p, True)
assert(p in DataStore['commentator'].sourcesForRelationship(MetaData.BelongsWith))
p.make_commentator(p, False)
assert(p not in DataStore['commentator'].sourcesForRelationship(MetaData.BelongsWith))
       

